/*
package com.jxj.weixin_gzh.util;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.extern.slf4j.Slf4j;
import net.logstash.logback.encoder.org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.MethodParameter;
import org.springframework.http.MediaType;
import org.springframework.http.server.ServerHttpRequest;
import org.springframework.http.server.ServerHttpResponse;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyAdvice;

import java.io.IOException;

@ControllerAdvice
@Slf4j
public class ShanDongShengYuHandler implements ResponseBodyAdvice {
 
    @Autowired
    private ObjectMapper objectMapper;
 
    @Override
    public boolean supports(MethodParameter returnType, Class converterType) {
        return true;
    }
 
    @Override
    public Object beforeBodyWrite(Object body, MethodParameter returnType, MediaType selectedContentType, Class selectedConverterType, ServerHttpRequest request, ServerHttpResponse response) {
        ResponseData d = new ResponseData();
        sensitiveHidden(body);
        d.setData(body);
        return d;
    }
 
 
    */
/**
     * 只支持自定义类型数据的敏感词过滤，考虑递归性能
     *//*

    private void sensitiveHidden(Object body) {
        if(body==null || StringUtils.isBlank(body.getClass().getName()) || !body.getClass().getName().contains("山东")){
            return;
        }
        int a = 0;
        Field[] declaredFields = body.getClass().getDeclaredFields();
        for (Field declaredField : declaredFields) {
            SensitiveWorldHidden annotation = declaredField.getAnnotation(SensitiveWorldHidden.class);
            log.warn("【注解类型】{}",annotation);
            try {
                declaredField.setAccessible(true);
                Object o = declaredField.get(body);
                if(annotation != null) {
                    String content = objectMapper.writeValueAsString(o);
                    content = content.replace("垃圾", "**");
                    Object replaced = objectMapper.readValue(content, o.getClass());
                    declaredField.set(body, replaced);
                }else {
                    sensitiveHidden(o);
                }
            } catch (IllegalAccessException e) {
                e.printStackTrace();
            } catch (JsonProcessingException e) {
                e.printStackTrace();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}
*/
